<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Abstract class for models
 */
require_once 'ModelAbstract.php';

/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 */
class Application_Model_Sessionformation extends Application_Model_ModelAbstract
{

    /**
     * Database var type int(50)
     *
     * @var int
     */
    protected $_IdSess;

    /**
     * Database var type int(100)
     *
     * @var int
     */
    protected $_FormationIdFor;

    /**
     * Database var type date
     *
     * @var date
     */
    protected $_DatedebpreSess;

    /**
     * Database var type date
     *
     * @var date
     */
    protected $_DatefinpreSess;

    /**
     * Database var type date
     *
     * @var date
     */
    protected $_DateDebSess;

    /**
     * Database var type date
     *
     * @var date
     */
    protected $_DateFinSess;

    /**
     * Database var type int(3)
     *
     * @var int
     */
    protected $_NbrparticipSess;

    /**
     * Database var type varchar(100)
     *
     * @var string
     */
    protected $_LieuSess;

    /**
     * Database var type varchar(45)
     *
     * @var string
     */
    protected $_RolesIdroles;

    /**
     * Database var type varchar(45)
     *
     * @var string
     */
    protected $_EtatSess;

    /**
     * Database var type varchar(8)
     *
     * @var string
     */
    protected $_ParticipantCin;

    /**
     * Database var type varchar(6)
     *
     * @var string
     */
    protected $_SalleIdSalle;


    /**
     * Parent relation fk_sessionformation_formation1
     *
     * @var Application_Model_Formation
     */
    protected $_Formation;

    /**
     * Parent relation fk_sessionformation_participant1
     *
     * @var Application_Model_Participant
     */
    protected $_Participant;

    /**
     * Parent relation fk_sessionformation_salle1
     *
     * @var Application_Model_Salle
     */
    protected $_Salle;


    /**
     * Dependent relation fk_sessionformation_has_participant_sessionformation1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_SessionformationHasParticipant
     */
    protected $_SessionformationHasParticipant;

    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'id_sess'=>'IdSess',
            'formation_id_for'=>'FormationIdFor',
            'datedebpre_sess'=>'DatedebpreSess',
            'datefinpre_sess'=>'DatefinpreSess',
            'date_deb_sess'=>'DateDebSess',
            'date_fin_sess'=>'DateFinSess',
            'nbrparticip_sess'=>'NbrparticipSess',
            'lieu_sess'=>'LieuSess',
            'roles_idroles'=>'RolesIdroles',
            'etat_sess'=>'EtatSess',
            'participant_cin'=>'ParticipantCin',
            'salle_id_salle'=>'SalleIdSalle',
        ));

        $this->setParentList(array(
            'FkSessionformationFormation1'=> array(
                    'property' => 'Formation',
                    'table_name' => 'Formation',
                ),
            'FkSessionformationParticipant1'=> array(
                    'property' => 'Participant',
                    'table_name' => 'Participant',
                ),
            'FkSessionformationSalle1'=> array(
                    'property' => 'Salle',
                    'table_name' => 'Salle',
                ),
        ));

        $this->setDependentList(array(
            'FkSessionformationHasParticipantSessionformation1' => array(
                    'property' => 'SessionformationHasParticipant',
                    'table_name' => 'SessionformationHasParticipant',
                ),
        ));
    }

    /**
     * Sets column id_sess
     *
     * @param int $data
     * @return Application_Model_Sessionformation
     */
    public function setIdSess($data)
    {
        $this->_IdSess = $data;
        return $this;
    }

    /**
     * Gets column id_sess
     *
     * @return int
     */
    public function getIdSess()
    {
        return $this->_IdSess;
    }

    /**
     * Sets column formation_id_for
     *
     * @param int $data
     * @return Application_Model_Sessionformation
     */
    public function setFormationIdFor($data)
    {
        $this->_FormationIdFor = $data;
        return $this;
    }

    /**
     * Gets column formation_id_for
     *
     * @return int
     */
    public function getFormationIdFor()
    {
        return $this->_FormationIdFor;
    }

    /**
     * Sets column datedebpre_sess
     *
     * @param date $data
     * @return Application_Model_Sessionformation
     */
    public function setDatedebpreSess($data)
    {
        $this->_DatedebpreSess = $data;
        return $this;
    }

    /**
     * Gets column datedebpre_sess
     *
     * @return date
     */
    public function getDatedebpreSess()
    {
        return $this->_DatedebpreSess;
    }

    /**
     * Sets column datefinpre_sess
     *
     * @param date $data
     * @return Application_Model_Sessionformation
     */
    public function setDatefinpreSess($data)
    {
        $this->_DatefinpreSess = $data;
        return $this;
    }

    /**
     * Gets column datefinpre_sess
     *
     * @return date
     */
    public function getDatefinpreSess()
    {
        return $this->_DatefinpreSess;
    }

    /**
     * Sets column date_deb_sess
     *
     * @param date $data
     * @return Application_Model_Sessionformation
     */
    public function setDateDebSess($data)
    {
        $this->_DateDebSess = $data;
        return $this;
    }

    /**
     * Gets column date_deb_sess
     *
     * @return date
     */
    public function getDateDebSess()
    {
        return $this->_DateDebSess;
    }

    /**
     * Sets column date_fin_sess
     *
     * @param date $data
     * @return Application_Model_Sessionformation
     */
    public function setDateFinSess($data)
    {
        $this->_DateFinSess = $data;
        return $this;
    }

    /**
     * Gets column date_fin_sess
     *
     * @return date
     */
    public function getDateFinSess()
    {
        return $this->_DateFinSess;
    }

    /**
     * Sets column nbrparticip_sess
     *
     * @param int $data
     * @return Application_Model_Sessionformation
     */
    public function setNbrparticipSess($data)
    {
        $this->_NbrparticipSess = $data;
        return $this;
    }

    /**
     * Gets column nbrparticip_sess
     *
     * @return int
     */
    public function getNbrparticipSess()
    {
        return $this->_NbrparticipSess;
    }

    /**
     * Sets column lieu_sess
     *
     * @param string $data
     * @return Application_Model_Sessionformation
     */
    public function setLieuSess($data)
    {
        $this->_LieuSess = $data;
        return $this;
    }

    /**
     * Gets column lieu_sess
     *
     * @return string
     */
    public function getLieuSess()
    {
        return $this->_LieuSess;
    }

    /**
     * Sets column roles_idroles
     *
     * @param string $data
     * @return Application_Model_Sessionformation
     */
    public function setRolesIdroles($data)
    {
        $this->_RolesIdroles = $data;
        return $this;
    }

    /**
     * Gets column roles_idroles
     *
     * @return string
     */
    public function getRolesIdroles()
    {
        return $this->_RolesIdroles;
    }

    /**
     * Sets column etat_sess
     *
     * @param string $data
     * @return Application_Model_Sessionformation
     */
    public function setEtatSess($data)
    {
        $this->_EtatSess = $data;
        return $this;
    }

    /**
     * Gets column etat_sess
     *
     * @return string
     */
    public function getEtatSess()
    {
        return $this->_EtatSess;
    }

    /**
     * Sets column participant_cin
     *
     * @param string $data
     * @return Application_Model_Sessionformation
     */
    public function setParticipantCin($data)
    {
        $this->_ParticipantCin = $data;
        return $this;
    }

    /**
     * Gets column participant_cin
     *
     * @return string
     */
    public function getParticipantCin()
    {
        return $this->_ParticipantCin;
    }

    /**
     * Sets column salle_id_salle
     *
     * @param string $data
     * @return Application_Model_Sessionformation
     */
    public function setSalleIdSalle($data)
    {
        $this->_SalleIdSalle = $data;
        return $this;
    }

    /**
     * Gets column salle_id_salle
     *
     * @return string
     */
    public function getSalleIdSalle()
    {
        return $this->_SalleIdSalle;
    }

    /**
     * Sets parent relation FormationIdFor
     *
     * @param Application_Model_Formation $data
     * @return Application_Model_Sessionformation
     */
    public function setFormation(Application_Model_Formation $data)
    {
        $this->_Formation = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['id_for'];
        }

        $this->setFormationIdFor($primary_key);

        return $this;
    }

    /**
     * Gets parent FormationIdFor
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Formation
     */
    public function getFormation($load = true)
    {
        if ($this->_Formation === null && $load) {
            $this->getMapper()->loadRelated('FkSessionformationFormation1', $this);
        }

        return $this->_Formation;
    }

    /**
     * Sets parent relation ParticipantCin
     *
     * @param Application_Model_Participant $data
     * @return Application_Model_Sessionformation
     */
    public function setParticipant(Application_Model_Participant $data)
    {
        $this->_Participant = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['cin'];
        }

        $this->setParticipantCin($primary_key);

        return $this;
    }

    /**
     * Gets parent ParticipantCin
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Participant
     */
    public function getParticipant($load = true)
    {
        if ($this->_Participant === null && $load) {
            $this->getMapper()->loadRelated('FkSessionformationParticipant1', $this);
        }

        return $this->_Participant;
    }

    /**
     * Sets parent relation SalleIdSalle
     *
     * @param Application_Model_Salle $data
     * @return Application_Model_Sessionformation
     */
    public function setSalle(Application_Model_Salle $data)
    {
        $this->_Salle = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['id_salle'];
        }

        $this->setSalleIdSalle($primary_key);

        return $this;
    }

    /**
     * Gets parent SalleIdSalle
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Salle
     */
    public function getSalle($load = true)
    {
        if ($this->_Salle === null && $load) {
            $this->getMapper()->loadRelated('FkSessionformationSalle1', $this);
        }

        return $this->_Salle;
    }

    /**
     * Sets dependent relations fk_sessionformation_has_participant_sessionformation1
     *
     * @param array $data An array of Application_Model_SessionformationHasParticipant
     * @return Application_Model_Sessionformation
     */
    public function setSessionformationHasParticipant(array $data)
    {
        $this->_SessionformationHasParticipant = array();

        foreach ($data as $object) {
            $this->addSessionformationHasParticipant($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_sessionformation_has_participant_sessionformation1
     *
     * @param Application_Model_SessionformationHasParticipant $data
     * @return Application_Model_Sessionformation
     */
    public function addSessionformationHasParticipant(Application_Model_SessionformationHasParticipant $data)
    {
        $this->_SessionformationHasParticipant[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_sessionformation_has_participant_sessionformation1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_SessionformationHasParticipant
     */
    public function getSessionformationHasParticipant($load = true)
    {
        if ($this->_SessionformationHasParticipant === null && $load) {
            $this->getMapper()->loadRelated('FkSessionformationHasParticipantSessionformation1', $this);
        }

        return $this->_SessionformationHasParticipant;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_Sessionformation
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_Sessionformation());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_Sessionformation::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getIdSess() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('id_sess = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getIdSess()));
    }
}
